﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using NPOI.HSSF.UserModel;
using NPOI.HPSF;
using NPOI.POIFS.FileSystem;
using NPOI.SS.UserModel;

namespace jzgl.Helper
{
    public class NPOIHelper
    {
        public HSSFWorkbook hssfworkbook;
        ISheet sheet;

        public void initlize()
        {
            hssfworkbook = new HSSFWorkbook();
            sheet = hssfworkbook.CreateSheet("test_01");




            POIFSFileSystem fs = new POIFSFileSystem();
            DirectoryEntry dir = fs.Root;


            dir.CreateDocument("Foo", new MemoryStream(new byte[] { 0x01, 0x02, 0x03 }));

            //create a folder
            dir.CreateDirectory("Hello");

            //create a POIFS file called Foo.poifs
            FileStream output = new FileStream("Foo.poifs", FileMode.OpenOrCreate);
            fs.WriteFileSystem(output);
            output.Close();





        }

        public IRow GetRow(int index)
        {
            IRow row = sheet.GetRow(index);
            if (row == null)
                row = sheet.CreateRow(index);
            return row;
        }

    }
}
